SELECT
<${r"#"}assign prefixName = true>
<#list entityMapper.fieldMapperMap?values as fieldMapper>
<${r"#"}if (select_${fieldMapper.code}??)>
${r"${prefixName?string('  ', ', ')}"}"${fieldMapper.columnName}"
<${r"#"}assign prefixName = false>
</${r"#"}if>
</#list>
<${r"#"}if prefixName>
*
</${r"#"}if>
FROM ${entityMapper.tableName}
<${r"#"}include "where.ftl">
<${r"#"}assign prefixName = true>
<#list entityMapper.fieldMapperMap?values as fieldMapper>
<${r"#"}if (order_by_${fieldMapper.code}??)>
${r"${prefixName?string('ORDER BY ', ', ')}"}"${fieldMapper.columnName}" ${r"$"}{order_by_${fieldMapper.code}_value!}
<${r"#"}assign prefixName = false>
</${r"#"}if>
</#list>